The present invention relates to computer systems. More specifically, the invention relates to providing template driven type and mode conversion for parameters in software applications.
Soon after the development of programming languages for computers, the concept of modular programming was developed. Modular programming encourages designing and writing programs as interactions among functions where each performs a single well-defined function.
For example, a call is made to a function. The function call typically specifies one or more parameters (or arguments). Each parameter has a specified type, which defines the meaning of the value of the parameter. The one or more bits passed in as a parameter are interpreted according to the format specified by the type (e.g., integer, floating point, string). In modern programming languages, there are a myriad of different types specified by standards, but the type refers to the format that should be utilized to give the bits meaning and therefore their value.
Parameters can also have different modes. The mode defines the relationship of the parameter between the caller and the callee (or function). For example, an “in” parameter is a parameter that is an input to the function. Even if the function modifies the parameter during execution, the modification will not affect the parameter from the caller's end.
An “out” parameter is a parameter that is an output of the function. Typically, the caller provides a pointer to a memory location (e.g., address) and the function writes the return value at that location. As with “in” parameters, the format of the parameter is specified by the type. Lastly, an “in out” parameter is one that is both an input and an output.
The above describes the basic initial concepts, but it may be beneficial to describe a typical, more complex application. FIG. 1 shows a database environment that uses different interfaces between components. A database 11 includes the hardware and software for performing, among other things, database queries. A Java virtual machine 13 executes computer programs that can interact with database 11.
As shown, Java Database Connectivity (“JDBC”) provides Application Programming Interfaces (“APIs”) for Java that supports Structure Query Language (“SQL”) commands to database 11. Additionally, SQLJ can be utilized to embed SQL statements in Java source code that interacts with JDBC. As is known, the APIs for JDBC have a defined call structure including parameter types and modes.
As shown, web services 15 of a web server communicates with Java virtual machine 13 utilizing Apache web service types and modes. Extensible Markup Language (“XML”) 17 is utilized to communicate input and output to web services 15 as specified by XML schemas.
Database 11 may have stored procedures that it would be desirable to access from web services 15. However, there may be call mismatches, such as parameter type and mode, that make this difficult. For example, the Oracle database system has stored procedures written in Procedural Language extensions to SQL (“PL/SQL”), which is different than web service types such as XML values used by Apache. A conversion may need to be performed in order to allow calls from web services 15 to stored procedures in database 11.
Additionally, PL/SQL supports parameters of in, out and in out. However, JDBC that provides calling mechanisms to database 11 sends a copy of each parameter. If the parameter is modified, a copy of the modified parameter is returned. Thus, the “before” and “after” values of the parameter appear in separate objects. This creates a mode inconsistency between these parameters.
One solution is for the programmer to manually write Java classes in order to allow access (or publish) to the stored procedures in database 11 by web services 15. Unfortunately, this solution is very time consuming and prone to errors.
A utility know as JPublisher has been developed by Oracle Corporation in order to, among other things, facilitate accessing SQL objects and PL/SQL in database 11. Although JPublisher has met with extreme success, interfaces to PL/SQL procedures are still manually created in many cases because the data types used by JDBC, and the way in which “out” or “in out” arguments are treated necessitates writing code by hand to match the intended usage.
Accordingly, it would be beneficial to have innovative techniques automatically publishing stored procedures of a database for use by other applications. Additionally, it would be beneficial to provide type and mode conversions where desired.